package components.tools.correction
{
	import UIFree.ObjectEvent;
	import UIFree.controls.uif_button;
	import UIFree.controls.uif_checkbox;
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import classes.clt_events;
	
	import components.clt_component;
	
	import flash.events.Event;
	import flash.geom.Rectangle;

	public class clt_correctionPanel extends clt_component {
		public function clt_correctionPanel(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
		}
		
		override protected function createComponents(): void {
			var inner: Rectangle = getInner();
			inner.inflate(-10, -10);
			(new uif_label(this, inner.x, inner.y, inner.width, 30, 'windowTitle')).text = app.classes.locale.CORRTITLE;
			inner.top += 40;
			
			var clearButton: uif_button = clt_clothingBase.button(this, inner.x + inner.width - 120, inner.y, 120, 33, 'Сбросить', function(e: Event): void {
				dispatchEvent(new Event(clt_events.CLEAR));
			});
			
			var cbAuto: uif_checkbox = new uif_checkbox(this, inner.x, inner.y, 300, 20, 'checkbox');
			inner.top += 25;
			
			cbAuto.text = app.classes.locale.AUTOCORRCAPTION;
			cbAuto.group = 'type_corr';
			var cbManual: uif_checkbox = new uif_checkbox(this, inner.x, inner.y, 300, 20, 'checkbox');
			inner.top += 25;
			
			cbManual.text = app.classes.locale.MANUALCORRCAPTION;
			cbManual.group = 'type_corr';
/*			var mcPanel: uif_label = new uif_label(this, inner.x, inner.y, inner.width, 120, 'lbLabel');
			mcPanel.text = 'Функция находиться в разработке, просим прощение за доставленное неудобство.';*/
			
			inner.width *= 0.55;
			var mcPanel: clt_manualCorrection = new clt_manualCorrection(this, inner.x, inner.y, inner.width, inner.height);
			var ahPanel: clt_autoCorrection = new clt_autoCorrection(this, inner.x, inner.y, inner.width, inner.height);
			
			inner.x += inner.width + 5;
			inner.width = getInner().width - inner.x;
			var stdPanel: clt_standartCorr = new clt_standartCorr(this, inner.x, inner.y, inner.width, inner.height);
			
			cbManual.addEvent(Event.CHANGE, function(e: Event): void {
				mcPanel.slideVisible(cbManual.checked);
				ahPanel.slideVisible(!cbManual.checked);
			});
			
			cbAuto.addEvent(Event.CHANGE, function(e: Event): void {
				(app as clt_clothingBase).workspace.dispatchEvent(new ObjectEvent(clt_events.AUTOCORRECTION, cbAuto.checked));
			});
			
			mcPanel.slideHide();
			cbAuto.checked = true;
		}
	}
}